package com.csii.user.service;

import com.csii.core.api.Result;
import com.csii.core.system.vo.ComboModel;
import com.csii.core.system.vo.SysPermissionDataRuleModel;
import com.csii.core.system.vo.SysUserCacheInfo;
import com.csii.user.entity.SysDepart;
import com.csii.user.entity.SysRole;
import com.csii.user.entity.SysUser;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Description TODO
 * @Date 2020/9/2 11:27
 * @Created by Ian
 * @Contact: 19107614@qq.com
 */
public interface ISysUserBaseService {

    @RequestMapping(value = "/sys/user/getUserByName", method = RequestMethod.GET)
    SysUser getUserByName(@RequestParam("userName") String userName);

    @RequestMapping(value = "/sys/user/getUserAll", method = RequestMethod.GET)
    List<SysUser> getUserAll(@RequestParam(value = "userNameList",required = false ) List<String> userNameList);

    @GetMapping("/sys/user/selectAllList")
    List<SysUser> selectAllList();

    @RequestMapping(value = "/sys/user/queryById", method = RequestMethod.GET)
    Result<SysUser> queryById(@RequestParam(name = "id", required = true) String id);

    @RequestMapping(value = "/listUserDepartList", method = RequestMethod.GET)
    Result<List<SysDepart>> listUserDepartList(@RequestParam(name = "userId", required = true) String userId);

    /**
     * 密码登录
     * @param grantType
     * @param userName
     * @param passWord
     * @param authorization
     * @return
     */
    @PostMapping(value = "/oauth/token")
    Map<String, String> loginByPassword(@RequestParam("grant_type") String grantType, @RequestParam("username") String userName, @RequestParam("password") String passWord,@RequestHeader("Authorization") String authorization );

    /**
     * 授权码登录
     * @param grantType
     * @param code
     * @param authorization
     * @return
     */
    @PostMapping(value = "/oauth/token")
    Map<String,String> loginByCode(@RequestParam("grant_type") String grantType, @RequestParam("code") String code, @RequestParam("redirect_uri")String  redirectUri, @RequestHeader("Authorization") String authorization );


    /**
     *
     * @param grantType
     * @param refreshToken
     * @param authorization
     * @return
     */
    @PostMapping(value = "/oauth/token")
    String refreshToken(@RequestParam("grant_type") String grantType, @RequestParam("refresh_token") String refreshToken,@RequestHeader("Authorization") String authorization );
    /**
     * 检查token获取权限
     * @return
     */
    @PostMapping(value = "/oauth/check_token")
    String checkToken(@RequestParam("token") String token,@RequestHeader("Authorization") String authorization);

    @PostMapping(value = "/sys/permission/sys/listDataRuleByUrl")
    Result<List<SysPermissionDataRuleModel>> listDataRuleByUrl(@RequestParam("requestPath") String requestPath, @RequestParam("requestMethod") String requestMethod, @RequestParam("component") String component);

    @RequestMapping(value = "/sys/user/getCacheUser", method = RequestMethod.GET)
    Result<SysUserCacheInfo> getCacheUser(@RequestParam("username") String username);
    /**
     * 获取所有有效用户
     * @return
     */
    @RequestMapping(value = "/sys/user/queryAllUser", method = RequestMethod.GET)
    List<ComboModel> queryAllUser();

    /**
     * 获取所有有效用户
     * @return
     */
    @RequestMapping(value = "/sys/user/getUsersByName/{name}", method = RequestMethod.GET)
    List<SysUser>getUsersByName(@PathVariable("name") String name);

    @GetMapping("/sys/sysDepart/getDepartIdsByUsername/{userName}")
    List<String> getDepartIdsByUsername(@PathVariable("userName") String userName);

    @GetMapping("/sys/sysDepart/getDepartNamesByUsername/{userName}")
    List<String> getDepartNamesByUsername(@PathVariable("userName") String userName);

    /**
     * 智慧文库所需要的部门接口
     * @return
     */
    @GetMapping("/sys/sysDepart/getDepartmentListAndUserIds")
    Result<List<SysDepart>> getDepartmentListAndUserIds();

    /**
     * 智慧文库所需的用户接口
     * @param userId
     * @return
     */
    @GetMapping("/sys/user/getUsersAndDepartId")
    Result<SysUser> getUsersAndDepartId(@RequestParam("userId") String userId);

    @GetMapping("/sys/sysDepart/getUserListByName")
    Result<List<SysUser>> getUserListByName(String name);

    /**
     * 工作流2.0所需的接口
     * @param deptName
     * @return
     */
    @GetMapping("/sys/sysDepart/queryDeptLikeDeptName")
    Result<List<SysDepart>> queryDeptLikeDeptName(@RequestParam("deptName") String deptName);

    /**
     * 工作流2.0所需的接口
     * @param userId
     * @return
     */
    @GetMapping("/sys/sysDepart/queryDeptCodeByUserId")
    Result<List<String>> queryDeptCodeByUserId(@RequestParam("userId") String userId);

    /**
     * 工作流2.0所需的接口
     * @param deptCodes
     * @return
     */
    @PostMapping("/sys/sysDepart/queryDeptByDeptCodes")
    Result<List<SysDepart>> queryDeptByDeptCodes(@RequestBody List<String> deptCodes);

    /**
     * 工作流2.0所需的接口
     * @param userId
     * @return
     */
    @RequestMapping(value = "/sys/role/queryRoleCodeByUserId", method = RequestMethod.GET)
    Result<List<String>> queryRoleCodeByUserId(@RequestParam(name="userId",required=true) String userId);


    /**
     * 工作流2.0所需的接口
     * @param roleName
     * @return
     */
    @RequestMapping(value = "/sys/role/queryRoleLikeRoleName", method = RequestMethod.GET)
    Result<List<SysRole>> queryRoleLikeRoleName(@RequestParam(name="roleName",required=true) String roleName);

    /**
     * 工作流2.0所需的接口
     * @param roleCodes
     * @return
     */
    @RequestMapping(value = "/sys/role/queryRoleByRoleCodes", method = RequestMethod.POST)
    Result<List<SysRole>> queryRoleByRoleCodes(@RequestBody List<String> roleCodes);

    /**
     * 工作流2.0所需的接口
     * @param usernameOrNickname
     * @return
     */
    @RequestMapping(value = "/sys/user/queryUserLikeUsernameOrNickname", method = RequestMethod.GET)
    Result<List<SysUser>> queryUserLikeUsernameOrNickname(@RequestParam(name="usernameOrNickname",required=true) String usernameOrNickname);

    /**
     * 工作流2.0所需的接口
     * @param usernames
     * @return
     */
    @RequestMapping(value = "/sys/user/queryUserByUsernames", method = RequestMethod.POST)
    public Result<List<SysUser>> queryUserByUsernames(@RequestBody List<String> usernames);


    /**
     * 工作流2.0所需的接口
     * @param roleCode
     * @return
     */
    @RequestMapping(value = "/sys/user/queryUserByRoleCode", method = RequestMethod.GET)
    Result<List<SysUser>> queryUserByRoleCode(@RequestParam(name="roleCode",required=true) String roleCode);

    /**
     * 工作流2.0所需的接口
     * @param username
     * @return
     */
    @RequestMapping(value = "/sys/user/queryHisLeadershipByUsername", method = RequestMethod.GET)
    Result<List<SysUser>> queryHisLeadershipByUsername(@RequestParam(name="username",required=true) String username);
}
